/**
 * Copyright (C), 2019-2019, 湖北奥莱斯轮胎有限公司
 * FileName: UploadUtil
 * Author:   xr
 * Date:     2019/12/23 18:05
 * Description:
 */
package com.rui.common.util;

import org.apache.tomcat.util.http.fileupload.FileUpload;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @author xr
 */
@Component
@Service
public class UploadUtil
{

    public static String BASE_DIR;
    public static String NGINX_PATH;

    public static String TMPFILE_PATH;

    @Value("${file.nginxPath}")
    public void setNginxPath(String nginxPath) {
        NGINX_PATH = nginxPath;
    }

    @Value("${file.baseDir}")
    public void setBaseDir(String baseDir) {
        BASE_DIR = baseDir;
    }

    @Value("${excel.tmpFilePath}")
    public static void setTmpFilePath(String tmpFilePath) {
        TMPFILE_PATH = tmpFilePath;
    }

    public static String getUrl(FileUpload fileUpload){
//       return UploadUtil.NGINX_PATH + FileUploadUtils.getFileUploadService().getFileUploadServiceExtend().getFileUrl(fileUpload);
        return null;
    }

    public static String convertUrl(String url){
        return url.replace(HttpUtil.getRequest().getContextPath(), UploadUtil.NGINX_PATH);
    }
}